#include "LocalClient.h"
#include "RemoteClient.h"

LocalClient::LocalClient()
{
   this->uid = -1;
   this->my_name = "\0";
   this->pos_x = 0;
   this->pos_y = 0;
   this->pos_z = 0;

}

LocalClient::LocalClient(int t_uid, char* name, int x, int y, int z)
{
   this->uid = t_uid;
   this->my_name = name;
   this->pos_x = x;
   this->pos_y = y;
   this->pos_z = z;
}

LocalClient::~LocalClient()
{

}

void LocalClient::Add_Message(const char* msg)
{
   this->Messages.push_back(msg);
}

void LocalClient::Add_User(RemoteClient User)
{
   this->Users.push_back(User);
}

RemoteClient LocalClient::Get_User(char* name)
{

   std::vector<RemoteClient>::iterator itUsers;

   for(itUsers = Users.begin(); itUsers != Users.end(); itUsers++)
   {
      if(strcmp(itUsers->Get_Name(),name) == 0)
      {
         return *itUsers;
      }
   }
   return NULL;
}

RemoteClient LocalClient::Get_User(int uid)
{
   std::vector<RemoteClient>::iterator itUsers;

   for(itUsers = Users.begin(); itUsers != Users.end(); itUsers++)
   {
      if(itUsers->Get_Uid() == uid)
      {
         return *itUsers;
      }
   }
   return NULL;
}

void LocalClient::Remove_User(int uid)
{
   std::vector<RemoteClient>::iterator itUsers;

   for(itUsers = Users.begin(); itUsers != Users.end(); itUsers++)
   {
      if(itUsers->Get_Uid() == uid)
      {
         this->Users.erase(itUsers,itUsers+1);
         break;
      }
   }
}

void LocalClient::Clear_Users()
{
   this->Users.clear();
}
